package fr.lelouet.tests.rmi.impl;

import java.rmi.RemoteException;

import fr.lelouet.tests.rmi.Controler;

public class ControlerImpl implements Controler {

	StringHandler handler;
	boolean receivedaction = false;

	public void waitForAction() {
		while (!receivedaction) {
			Thread.yield();
		}
	}

	@Override
	public void action() throws RemoteException {
		receivedaction = true;
		System.out.println("action");
	}

	@Override
	public void setHandler(StringHandler sh) throws RemoteException {
		this.handler = sh;
	}

	public void send(String str) {
		try {
			handler.onString(str);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}

}